{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "64a7d7a1-e882-4f4b-b85e-8564c1e22ad1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0    5000\n",
      "1    6000\n",
      "2    7000\n",
      "3    8000\n",
      "4    9000\n",
      "Name: 月工资收入, dtype: int64\n"
     ]
    },
    {
     "ename": "AttributeError",
     "evalue": "'DataFrame' object has no attribute 'append'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[1], line 14\u001b[0m\n\u001b[0;32m     12\u001b[0m \u001b[38;5;66;03m# 增加一位员工信息\u001b[39;00m\n\u001b[0;32m     13\u001b[0m new_employee \u001b[38;5;241m=\u001b[39m {\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m姓名\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m赵一平\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m性别\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m男\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m年龄\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;241m34\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m月工资收入\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;241m7000\u001b[39m}\n\u001b[1;32m---> 14\u001b[0m df \u001b[38;5;241m=\u001b[39m df\u001b[38;5;241m.\u001b[39mappend(new_employee, ignore_index\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m     15\u001b[0m \u001b[38;5;66;03m# 修改赵一平的月工资收入\u001b[39;00m\n\u001b[0;32m     16\u001b[0m df\u001b[38;5;241m.\u001b[39mloc[df[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m姓名\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m赵一平\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m月工资收入\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m8000\u001b[39m\n",
      "File \u001b[1;32mC:\\Anaconda\\Lib\\site-packages\\pandas\\core\\generic.py:6299\u001b[0m, in \u001b[0;36mNDFrame.__getattr__\u001b[1;34m(self, name)\u001b[0m\n\u001b[0;32m   6292\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (\n\u001b[0;32m   6293\u001b[0m     name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_internal_names_set\n\u001b[0;32m   6294\u001b[0m     \u001b[38;5;129;01mand\u001b[39;00m name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_metadata\n\u001b[0;32m   6295\u001b[0m     \u001b[38;5;129;01mand\u001b[39;00m name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_accessors\n\u001b[0;32m   6296\u001b[0m     \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_info_axis\u001b[38;5;241m.\u001b[39m_can_hold_identifiers_and_holds_name(name)\n\u001b[0;32m   6297\u001b[0m ):\n\u001b[0;32m   6298\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m[name]\n\u001b[1;32m-> 6299\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mobject\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;21m__getattribute__\u001b[39m(\u001b[38;5;28mself\u001b[39m, name)\n",
      "\u001b[1;31mAttributeError\u001b[0m: 'DataFrame' object has no attribute 'append'"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "# 创建包含 5 位员工信息的 DataFrame\n",
    "data = {\n",
    "    '姓名': ['张三', '李四', '王五', '赵六', '孙七'],\n",
    "    '性别': ['男', '女', '男', '女', '男'],\n",
    "    '年龄': [25, 30, 35, 40, 45],\n",
    "    '月工资收入': [5000, 6000, 7000, 8000, 9000]\n",
    "}\n",
    "df = pd.DataFrame(data)\n",
    "# 选择月工资收入这列数据\n",
    "print(df['月工资收入'])\n",
    "# 增加一位员工信息\n",
    "new_employee = {'姓名': '赵一平', '性别': '男', '年龄': 34, '月工资收入': 7000}\n",
    "df = df.append(new_employee, ignore_index=True)\n",
    "# 修改赵一平的月工资收入\n",
    "df.loc[df['姓名'] == '赵一平', '月工资收入'] = 8000\n",
    "# 删除第 2 位员工的数据\n",
    "df = df.drop(1)\n",
    "# 筛选出月工资收入大于 6000 元的员工数据\n",
    "filtered_df = df[df['月工资收入'] > 6000]\n",
    "print(filtered_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "028e68cd-d0bb-4268-b0c9-316048b367d1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "===============信计221========刘显婷============224180117=================\n",
      "   姓名 性别  年龄  月工资收入\n",
      "0  张三  男  25   5000\n",
      "1  李四  女  30   6000\n",
      "2  王五  男  35   7000\n",
      "3  赵六  女  40   8000\n",
      "4  孙七  男  45   9000\n",
      "0    5000\n",
      "1    6000\n",
      "2    7000\n",
      "3    8000\n",
      "4    9000\n",
      "Name: 月工资收入, dtype: int64\n",
      "    姓名 性别  年龄  月工资收入\n",
      "2   王五  男  35   7000\n",
      "3   赵六  女  40   8000\n",
      "4   孙七  男  45   9000\n",
      "5  赵一平  男  34   8000\n",
      "信计221 刘显婷 224180117\n"
     ]
    }
   ],
   "source": [
    "print(\"===============信计221========刘显婷============224180117=================\")\n",
    "import pandas as pd\n",
    "# 创建包含 5 位员工信息的 DataFrame\n",
    "data = {\n",
    "    '姓名': ['张三', '李四', '王五', '赵六', '孙七'],\n",
    "    '性别': ['男', '女', '男', '女', '男'],\n",
    "    '年龄': [25, 30, 35, 40, 45],\n",
    "    '月工资收入': [5000, 6000, 7000, 8000, 9000]\n",
    "}\n",
    "df = pd.DataFrame(data)\n",
    "print(df)\n",
    "# 选择月工资收入这列数据\n",
    "print(df['月工资收入'])\n",
    "# 增加一位员工信息\n",
    "new_employee = pd.DataFrame({'姓名': ['赵一平'], '性别': ['男'], '年龄': [34], '月工资收入': [7000]})\n",
    "df = pd.concat([df, new_employee], ignore_index=True)\n",
    "# 修改赵一平的月工资收入\n",
    "df.loc[df['姓名'] == '赵一平', '月工资收入'] = 8000\n",
    "# 删除第 2 位员工的数据\n",
    "df = df.drop(1)\n",
    "# 筛选出月工资收入大于 6000 元的员工数据\n",
    "filtered_df = df[df['月工资收入'] > 6000]\n",
    "print(filtered_df)\n",
    "print(\"信计221 刘显婷 224180117\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "deb11f4f-c1b8-4024-af89-ce01b93b6cb6",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "402f4e31-fc40-4024-a9b8-646c825b19e0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
